package com.android.music.prolyric;

import java.util.ArrayList;

import android.app.Activity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.TextView;

import com.android.music.prolyric.songmanager.Song;

class ListSongAdapter extends ArrayAdapter<Song>
{
	private final ArrayList<Song> list;
	  private final Activity context;

	public ListSongAdapter(Activity  context, ArrayList<Song> list) {
		super(context, R.layout.songs_row,list);
		this.context = context;
		this.list = list;
		// TODO Auto-generated constructor stub
	}
	
	
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		View view = null;
	    if (convertView == null) {
	      LayoutInflater inflator = context.getLayoutInflater();
	      view = inflator.inflate(R.layout.songs_row, null);
	      final ViewHolder viewHolder = new ViewHolder();
	      viewHolder.musicImg = (ImageView) view.findViewById(R.id.search_row_img);
	      viewHolder.tv_songname = (TextView) view.findViewById(R.id.search_row_songname);
	      viewHolder.tv_singer = (TextView)view.findViewById(R.id.search_row_singer);
	      view.setTag(viewHolder);
	     
	    } else {
	      view = convertView;
	     
	    }
	    ViewHolder holder = (ViewHolder) view.getTag();
	    String songname = list.get(position).getSong_display_name();
	    songname = songname.substring(0,songname.length()-4);
	    holder.tv_songname.setText(songname);
	    holder.tv_singer.setVisibility(View.GONE);
	    return view;
	  
	}

	
	
	
	
	  static class ViewHolder {
		  protected ImageView musicImg;
		  protected TextView tv_songname;
		  protected TextView tv_singer;
		   
		    
		  }

	
}